package com.ivvi.autoreco.opencv;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.ivvi.autoreco.R;

import org.opencv.ivvi.custom.BitmapHelper;
import org.opencv.ivvi.custom.CropType;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by duanxianping on 2017/6/7.
 */

public class ZFTActivity extends AppCompatActivity {

    @BindView(R.id.iv_ori)
    ImageView ivOri;
    @BindView(R.id.iv_ori_zft)
    ImageView ivOriZft;
    @BindView(R.id.iv_left)
    ImageView ivLeft;
    @BindView(R.id.iv_left_zft)
    ImageView ivLeftZft;
    @BindView(R.id.iv_right)
    ImageView ivRight;
    @BindView(R.id.iv_right_zft)
    ImageView ivRightZft;
    @BindView(R.id.iv_top)
    ImageView ivTop;
    @BindView(R.id.iv_top_zft)
    ImageView ivTopZft;
    @BindView(R.id.iv_bottom)
    ImageView ivBottom;
    @BindView(R.id.iv_bottom_zft)
    ImageView ivBottomZft;
    @BindView(R.id.iv_ori_gray)
    ImageView ivOriGray;
    @BindView(R.id.iv_left_gray)
    ImageView ivLeftGray;
    @BindView(R.id.iv_right_gray)
    ImageView ivRightGray;
    @BindView(R.id.iv_top_gray)
    ImageView ivTopGray;
    @BindView(R.id.iv_bottom_gray)
    ImageView ivBottomGray;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zft);
        ButterKnife.bind(this);

        Bitmap ori = BitmapHelper.compress("/storage/emulated/0/DCIM/3D1/美女3D/26.jpg", 160, 90);

        Bitmap left = BitmapHelper.createBitmap(ori, CropType.LEFT);
        Bitmap right = BitmapHelper.createBitmap(ori, CropType.RIGHT);
        Bitmap top = BitmapHelper.createBitmap(ori, CropType.TOP);
        Bitmap bottom = BitmapHelper.createBitmap(ori, CropType.BOTTOM);

        ivLeft.setImageBitmap(left);
        ivRight.setImageBitmap(right);
        ivTop.setImageBitmap(top);
        ivBottom.setImageBitmap(bottom);


        Bitmap leftGray = Helper.getGray(left);
        Bitmap rightGray = Helper.getGray(right);
        Bitmap topGray = Helper.getGray(top);
        Bitmap bottomGray = Helper.getGray(bottom);

        ivLeftGray.setImageBitmap(leftGray);
        ivRightGray.setImageBitmap(rightGray);
        ivTopGray.setImageBitmap(topGray);
        ivBottomGray.setImageBitmap(bottomGray);


        Bitmap leftZft = Helper.hist(left);
        Bitmap rightZft = Helper.hist(right);
        Bitmap topZft = Helper.hist(top);
        Bitmap bottomZft = Helper.hist(bottom);

        ivLeftZft.setImageBitmap(leftZft);
        ivRightZft.setImageBitmap(rightZft);
        ivTopZft.setImageBitmap(topZft);
        ivBottomZft.setImageBitmap(bottomZft);

    }

}
